<script setup lang="ts">
import { ref, reactive } from 'vue'
import { FormType } from './components/form/types'
import { Notification } from './components/notification/Notification.js'
const model = reactive({
  username: '',
  password: ''
})
// 获取表单实例
const myForm = ref<FormType>()
const rules = reactive({
  username: [
    {
      required: true,
      message: '请输入用户名！'
    }
  ],
  password: [
    {
      required: true,
      message: '请输入密码！'
    }
  ]
})
const login = () => {
  myForm.value?.validate((isValid) => {
    if (isValid) {
      console.log(model)
    } else {
      alert('请正确填写表单！')
    }
  })
}

function handleNotification() {
  Notification({
    title: 'test',
    message: '测试Message'
  })
}
// let b
// console.log(a)
</script>

<template>
  <el-container>
    <el-header>Header</el-header>
    <el-container>
      <el-aside width="200px">
        <el-button size="large" type="success" @click="handleNotification"
          >handleNotification</el-button
        >
        <el-button round type="primary">Primary</el-button>
        <el-button size="small" type="success">Success</el-button>
        <el-button type="info">Info</el-button>
        <el-button type="warning">Warning</el-button>
        <el-button type="danger">Danger</el-button>
      </el-aside>
      <el-main>
        <!-- <el-notification title="test" message="测试Message"></el-notification> -->
        <el-form ref="myForm" :model="model" :rules="rules">
          <el-form-item label="用户名：" prop="username">
            <el-input v-model="model.username" />
          </el-form-item>
          <el-form-item label="密码：" prop="password">
            <el-input v-model="model.password" type="password" />
          </el-form-item>
          <br />
          <el-form-item>
            <el-button type="primary" @click="login"> 登 录 </el-button>
          </el-form-item>
        </el-form></el-main
      >
    </el-container>

    <el-footer>Footer</el-footer>
  </el-container>
</template>

<style scoped>
/* header {
  z-index: -1;
  width: 100px;
  max-height: 100vh;
  line-height: 1.5;
}

.logo {
  display: block;
  margin: 0 auto 2rem;
}

nav {
  width: 100%;
  margin-top: 2rem;
  font-size: 12px;
  text-align: center;
}

nav a.router-link-exact-active {
  color: var(--color-text);
}

nav a.router-link-exact-active:hover {
  background-color: transparent;
}

nav a {
  display: inline-block;
  padding: 0 1rem;
  border-left: 1px solid var(--color-border);
}

nav a:first-of-type {
  border: 0;
}

@media (width >= 1024px) {
  header {
    display: flex;
    place-items: center;
    padding-right: calc(var(--section-gap) / 2);
  }

  .logo {
    margin: 0 2rem 0 0;
  }

  header .wrapper {
    display: flex;
    flex-wrap: wrap;
    place-items: flex-start;
  }

  nav {
    padding: 1rem 0;
    margin-top: 1rem;
    margin-left: -1rem;
    font-size: 1rem;
    text-align: left;
  }
} */
</style>
